package cn.topcodes.tcsf.admin.scheduling;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author unicorn
 */
public class QuartzJobFactory implements Job {

    private static Logger logger = LoggerFactory.getLogger(QuartzJobFactory.class);

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        ScheduleJob scheduleJob = (ScheduleJob)context.getMergedJobDataMap().get("scheduleJob");
        logger.info("执行任务 " + scheduleJob.getJobGroup() + "-" + scheduleJob.getJobName());
        Object[] params = scheduleJob.getParams() != null ? scheduleJob.getParams() : new Object[0];
        ScheduleServiceImpl.invokMethod(scheduleJob, params);
    }
}